home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 2
/
Gekikoh Dennoh Club Vol. 2 (Japan).7z
/
Gekikoh Dennoh Club Vol. 2 (Japan) (Track 01).bin
/
kowin
/
font
/
tcwin24s.lzh
/
tc_win.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-05
|
9KB
|
382 lines
/*/ ******************************************************************* /*/
/*/ /*/
/*/ TC_WIN.win version 1.00 小笠原博之 SPS0783 COR. /*/
/*/ /*/
/*/ v1.10 1991 03/11 : Ko-Window 2.10 の UserSheet 対応 /*/
/*/ v1.20 1992 01/15 : 漢字対応 /*/
/*/ /*/
/*/ ******************************************************************* /*/
#include <stdio.h>
#include <wlib.h>
#include <parts.h>
#include <winop.h>
/*#include "mpat.h"*/
#define in(a,b,c,d) (info->x>=(a) && info->x<(c) && info->y>=(b) && info->y<(d))
#include "tc_win.h"
/*/
/* イベント定義
/*/
#define UskEVENT1 (EventOpenON \
|EventRedrawON \
|EventCloseON \
|EventResizeON \
|EventUserON \
|EventKeyON \
|EventMouseSwitchON)
#define UskEVENT2 (EventOpenON \
|EventRedrawON \
|EventCloseON \
|EventUserON \
|EventKeyON \
|EventMouseSwitchON)
int UskWindowExec1();
int UskWindowExec2();
/* 24*24 = 3byte * 24 = 72byte */
/*int WindowHeapSize= ((MAXCHAR*32)/1024+5)*1024;*/
int WindowHeapSize= ((MAXCHAR*72)/1024+5)*1024;
#define TCBUFSIZE ((MAXCHAR*72)/1024+1)*1024;
#define TCBUFSIZE2 ((MAXCHAR2*72)/1024+1)*1024;
#define UMES 32
#define mKAIJO 0
#define mSAKUJO 1
#define mKOUKAN 2
#define mFUKUSHA 3
#define mGOUSEI 4
short Gmode= FALSE;
int TcBufSize= TCBUFSIZE;
int MaxChar= MAXCHAR;
char *tcfont; /* TC FONT BUFFER */
Sheet tcbuf= { /* TC FONT Sheet DATA */
/*256, /* .h */
24*16,
/*112*16, /* .v */
112*24,
/*16 /* .hword */
24*16/16
};
char fname[80]; /* file name */
int mode= mKAIJO; /* exec mode */
int xxflag= FALSE; /* カーソル ON/OFF */
int xx, /* カーソル位置 */
yy; /* カーソル位置 */
int editflag= FALSE; /* 編集スイッチ */
DrawBuf OYA_dbuf[14]; /* 親ウィンドウ表示バッファ */
char redrawmsg[90];
void
WindowMain( argc, argv )
char **argv;
{
WindowID wp;
int x= 2,
y= 2,
h= 24*16+14,
v= 200;
/*/
/* オプション解析
/*/
*fname= '\0';
*redrawmsg= '\0';
argc= AnalyzeArgs( argc, argv, &x, &y, &h, &v );
while( --argc ){
if( **++argv == '-' ){
;
}else{
strcpy( fname, *argv );
setfname( fname );
}
}
if( Gmode ){
TcBufSize= TCBUFSIZE2;
MaxChar= MAXCHAR2;
tcbuf.v= (MAXCHAR2/16+1)*24;
}
tcfont= (char*)malloc( TcBufSize );
if( tcfont == NULL ){
ErrorMessage( "メモリが確保できません(HEAPを拡張して下さい)",ERROR_OK );
WindowSendSignal( WindowProcessID, SignalKill, NULL );
return;
}
memset( tcfont, 255, TcBufSize );
tcbuf.buf1=
tcbuf.buf2= (short*)tcfont;
/* 親ウィンドウ */
wp = WindowTitleOpen( x, y, h, v+UMES, NULL, "TC font-24\0 Copyright 1991-93 H.Ogasawara COR.", Close|Push|Resize, UskWindowExec1 );
WindowSetEventAttr( wp, UskEVENT1 );
/* 子ウィンドウ */
WindowSetEventAttr( WindowScrollOpen( 0, UMES, h, v, wp, 24*16, (MaxChar+15)/16*24, DirectionX|DirectionY, 16, 24, UskWindowExec2 ), UskEVENT2 );
}
/*************************************\
親ウィンドウ処理
\*************************************/
UskWindowExec1( wp, info )
WindowID wp;
EventInfo *info;
{
WindowID cwp= WindowGetChildTop( wp );
char *err= 0;
static short nored= 0;
switch( info->option ){
case EventOpen:
DrawSetClear( OYA_dbuf, 1 );
DrawSetSymbol( OYA_dbuf+1, 4, 1, "名前 書込 選択 解除 消去 交換 複写 合成", 9, 12 );
DrawSetLine( OYA_dbuf+2, 2, 1, 6*4+4, 13, ShadowUp, OptionShadow );
DrawSetLine( OYA_dbuf+3, 6*5-2+4, 1, 6*8+12, 13, ShadowUp, OptionShadow );
DrawSetLine( OYA_dbuf+4, 6*10-2+4, 1, 6*13+12, 13, ShadowUp, OptionShadow );
DrawSetLine( OYA_dbuf+5, 2, 1+16, 260, 14+16, ShadowDown, OptionShadow );
strcpy( redrawmsg, fname );
if( *fname ){
nored= 1;
WindowRedraw( wp );
err= (char*)Tc_load( wp, fname );
nored= 0;
}
WindowRedraw( wp );
if( err )
UskMes( err, wp );
return TRUE;
case EventRedraw:
if( nored ){
DrawBuf dbuf[1];
DrawSetClear( dbuf, 1 );
WindowDraw( wp, dbuf, 1 );
}else{
int i;
DrawSetSymbol( OYA_dbuf+6, 5, 2+16, redrawmsg, 9, 12 );
for( i=0 ; i<5 ; i++ )
DrawSetLine( OYA_dbuf+7+i, i*30+112-2, 1, i*30+110+28, 13, mode==i ? ShadowDown : ShadowUp, OptionShadow );
WindowDraw( wp, OYA_dbuf, 7+5 );
WindowSendEvent( cwp, info );
}
return TRUE;
case EventClose:
if( editflag ){
if( OK( "TC_WIN:データをセーブしますか?", fname ) ){
if( *fname == '\0' ){
extern int defchar;
strcpy( fname, "TC$(^_^).fon" );
defchar= MaxChar;
}
Tc_save( wp, fname );
}
}
WindowClose( wp );
WindowConnectionClose();
return TRUE;
case EventResize:
WindowResize( cwp, 0, UMES, info->h, info->v-16-16 );
WindowResize( wp, info->x, info->y, info->h, info->v );
break;
case EventUser: {
switch( info->ComData ){
case UserStrings:
(char*)(info->ComBuffer)= *(char**)(info->ComBuffer);
case UserPaste:
case UserString:
strcpy( fname, (char*)(info->ComBuffer) );
setfname( fname );
if( editflag ){
if( !OK( "セーブしていません。このまま読み込むと", "内容が書き換わります。よろしいですか?" ) ){
UskMes( "キャンセルしました", wp );
return TRUE;
} /**/
}
UskMes( "読み込み中", wp );
err= (char*)Tc_load( wp, fname );
WindowRedraw( wp );
if( err )
UskMes( err, wp );
editflag= FALSE;
break;
case UserSheet:
case 256:
/* default: */
User_font( wp, info );
}
return TRUE;
}
case EventMouseSwitch:
if( info->y >= 32 ){
info->y -= 32;
WindowSendEvent( cwp, info );
}else if( info->LeftON && info->y < 16 ){
if( in( 2, 1, 6*4+4, 13 ) ){
Tc_rename( wp, fname );
}else if( in( 6*5-2+4, 1, 6*8+12, 13 ) ){
Tc_save( wp, fname );
}else if( in( 6*10-2+4, 1, 6*13+12, 13) ){
tcmenu( wp, info );
}else if( info->x > 112-2 && info->x < 112-2+30*5 ){
DrawBuf dbuf[6];
int i;
mode= (info->x - 112) / 30;
modechg:
for( i=0 ; i<5 ; i++ )
DrawSetLine( dbuf+i, i*30+112-2, 1, i*30+110+28, 13, mode==i ? ShadowDown : ShadowUp, OptionShadow );
WindowDraw( wp, dbuf, 5 );
if( mode < 2 && xxflag )
curon( cwp, FALSE );
}
}else if( info->RightON && in( 6*5-2+4, 1, 6*8+12, 13 ) ){
Tc_save( wp, fname );
}else if( info->LeftON && info->y > 16 && info->y < 32 ){
SendData( wp, info, UserString, redrawmsg );
}else
return FALSE;
return TRUE;
case EventKey:
switch( info->KeyCode ){
case FuncKey+6:
case FuncKey+7:
case FuncKey+8:
case FuncKey+9:
case FuncKey+10:
mode= info->KeyCode - (FuncKey+6);
goto modechg;
case 'N'&31:
Tc_rename( wp, fname );
break;
case 'S'&31:
Tc_save( wp, fname );
break;
default:
info->y -= 32;
WindowSendEvent( cwp, info );
}
return TRUE;
}
return FALSE;
}
/*************************************\
スクロールウィンドウ処理
\*************************************/
UskWindowExec2( wp, info )
WindowID wp;
EventInfo *info;
{
DrawBuf dbuf[3];
switch( info->option ){
case EventOpen:
WindowRedraw( wp );
return TRUE;
case EventRedraw:
DrawSetPut( dbuf, 0, 0, &tcbuf );
if( xxflag ){
DrawSetLine( dbuf+1,xx,yy,xx+23,yy+23,3|OptionXor, OptionFill );
WindowDraw( wp, dbuf, 2 );
}else
WindowDraw( wp, dbuf, 1 );
return TRUE;
case EventMouseSwitch: {
DrawBuf dbuf[6];
int x= info->x / 24;
int y= info->y / 24;
if( info->LeftON ){
if( mode == 0 ){
send_User_font( wp, info );
}else if( mode == 1 ){
/* 消去 */
del1char( wp, x, y );
}else if( mode >= 2 && x < 16 ){
if( xxflag ){
unsigned short font1[48];
unsigned short font2[48];
int i;
editflag= TRUE;
if( !(info->ShiftStat & 4) )
curon( wp, FALSE );
get1char( xx/24, yy/24, font1 );
get1char( x, y, font2 );
switch( mode ){
case 2: /* 交換 */
put1char( wp, x, y, font1 );
put1char(wp,xx/24,yy/24,font2);
break;
case 4: /* 合成 */
for( i=0 ; i<24 ; i++ )
font1[i]&=font2[i];
case 3: /* 複写 */
put1char( wp, x, y, font1 );
break;
}
}else{
xx= x*24;
yy= y*24;
curon( wp, TRUE );
}
}
}else if( info->RightON ){
if( xxflag )
curon( wp, FALSE );
else
fontcode( wp, info );
}
return TRUE;
}
case EventKey:
if( info->KeyCode == ' ' )
fontcode( wp, info );
return TRUE;
}
return FALSE;
}
/*************************************\
メッセージ表示
\*************************************/
UskMes( str, wp )
char *str;
WindowID wp;
{
DrawBuf buf[2];
DrawSetSymbol( buf, 5, 2+16, " ", 9, 12 );
DrawSetSymbol( buf+1, 5, 2+16, str, 9, 12 );
strcpy( redrawmsg, str );
WindowDraw( wp, buf, 2 );
}
curon( wp, a )
WindowID wp;
int a;
{
DrawBuf dbuf[1];
xxflag= a;
DrawSetLine( dbuf, xx, yy, xx+23, yy+23, 3|OptionXor, OptionFill );
WindowDraw( wp, dbuf, 1 );
}